package com.sky.service.admin.impl;

import com.sky.mapper.admin.ReportMapper;
import com.sky.result.Result;
import com.sky.service.admin.ReportService;
import com.sky.vo.TurnoverReportVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class ReportServvicelmpl implements ReportService {
    @Resource
    ReportMapper reportMapper;
    @Override
    public Result<TurnoverReportVO> turnoverStatistics(LocalDate begin, LocalDate end) {
        List<LocalDate> dateList = reportMapper.turnoverStatistics(begin, end);
        String join = StringUtils.join(dateList, ",");
        System.err.println("日期"+join);
        List<BigDecimal> bigDecimals = reportMapper.selectAmount(begin, end);
        String join1 = StringUtils.join(bigDecimals, ",");
        System.err.println("金额"+join1);
        TurnoverReportVO build = TurnoverReportVO.builder().turnoverList(join1).dateList(join).build();
        return Result.success(build);
    }
}
